﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coldairarrow.Business.Goods;
using Coldairarrow.Entity.DTO;
using Coldairarrow.IBusiness.Goods;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;

namespace Coldairarrow.Api.Controllers.WeChat
{
    [Route("/WeChat/[controller]/[action]")]
    public class WeChat_GoodsDetailController : BaseApiController
    {
        public WeChat_GoodsDetailController(IBTB_GoodsBusiness bTB_GoodsBus, IBTB_HomeBusiness bTB_HomeBus)
        {
            _bTB_GoodsBus = bTB_GoodsBus;
            _bTB_HomeBus = bTB_HomeBus;
        }
        IBTB_GoodsBusiness _bTB_GoodsBus { get; }
        IBTB_HomeBusiness _bTB_HomeBus;
        /// <summary>
        /// 指定查询
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<BTB_GoodsDto>> GetDataList(IdInputDTO input)
        {
            return await _bTB_GoodsBus.GetDataList(input.id);
        }

        /// <summary>
        /// 前台——获取商品详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [NoCheckJWT]
        public async Task<List<BTB_GoodsDto>> GetGoodData(IdInputDTO input)
        {
            List<BTB_GoodsDto> dList = new List<BTB_GoodsDto>();
            var model = await _bTB_GoodsBus.GetsGootDataAsync(input.id);
            if (!model.IsNullOrEmpty())
            {
                dList.Add(model);
            }
            
            return dList;
        }

        /// <summary>
        /// 获取所有商品列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<PageResult<BTB_GoodsDto>> GetListAll(PageInput<BTB_GoodsTypeDto> input)
        {
            return await _bTB_HomeBus.GetDataListAsync(input);
        }
        /// <summary>
        /// 特惠列表
        /// </summary>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public async Task<List<BTB_GoodsDto>> GetPreferentialListAsync()
        {
            return await _bTB_HomeBus.GetPreferentialListAsync();
        }
        /// <summary>
        /// 规格列表
        /// </summary>
        /// <param name="input">商品id</param>
        /// <returns></returns>
        [NoCheckJWT]
        [HttpPost]
        public List<GoodsSpecificationsDTO> Specifications(IdInputDTO input)
        {
            return _bTB_HomeBus.Specifications(input.id);
        }
    }
}
